<template>
    <div>
        <button v-on:click='start'>开始任务</button>
    </div>
</template>
<script>
    import {
        defineComponent,
        ref,
        onMounted,onUnmounted
    } from 'vue'
    import {
        useRouter
    } from 'vue-router'

    export default defineComponent({
        name: 'Start',
        setup() {
            onUnmounted(()=>{
                //组件卸载时的生命周期
                //消除定时器，消除闭包函数等等
                console.info('onUnmounted')
            })
            onMounted(() => {
                //组件挂载的过程
                //数据dom
                console.info("onMounted")
            })
            console.info('setup')
            let name = ref('jack')
            let num = ref(100)
            let obj = {
                message: 'start'
            }
            let router = useRouter();
            let start = () => {
                //router.push("/home")
                router.push({
                    path: "/home",
                    query: {
                        name: name.value,
                        num: num.value,
                        obj: JSON.stringify(obj)
                    }
                })
            }
            return {
                start,
                name,
                num,
                obj
            }

        },
    })
</script>